﻿using System;
using System . Collections . Generic;
using System . Collections . ObjectModel;
using System . Reflection;
using System . IO;
using System . Threading . Tasks;
using System . Linq;
using System . Xml . Linq;
using System . Xml;
using System . Text;


namespace GameClassLibrary . Maps
{
    public class MapProxy
    {
        public string Name { get; set; }

        public string FileName { get; set; }

        public Uri Image { get; set; }

        public Map Map
        {
            get
            {
                return new Map ( );
            }
        }

        public static List<MapProxy> GetMapList ( )
        {
            Assembly assembly = Assembly.GetExecutingAssembly( );

            Stream stream = assembly.GetManifestResourceStream( @"MapsResource.Index.xml");

            StreamReader reader=new StreamReader ( stream );

            XDocument Doc= XDocument . Parse ( reader . ReadToEnd ( ) );

            var a=from p in Doc.Descendants()
                  select new MapProxy
                  {
                      Name=( string ) p . Attribute("Name"),
                      FileName=( string ) p . Attribute("FileName"),
                      Image=new Uri( ( string ) p . Attribute( "Image" ) )
                  };

            List<MapProxy> temp=new List<MapProxy>();

            temp . AddRange ( a );

            return temp;
        }

    }
}
